﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3_简单工厂设计模式
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("输入您的笔记本:");
            string s = Console.ReadLine();
            NoteBook nb = GetBook(s);
            nb.SaiHi();
            Console.ReadKey();
        }

        public static NoteBook GetBook(string s)
        {
            NoteBook nb = null;

            switch (s)
            {
                case "Acer":nb = new Acer();
                    break;
                case "Dell":nb = new Dell();
                    break;
                case "MiBook":nb = new MiBook();
                    break;
            }
            return nb;
        }
    }

    public abstract class NoteBook
    {
        public abstract void SaiHi();
    }

    public class Acer : NoteBook
    {
        public override void SaiHi()
        {
            Console.WriteLine("我是宏基笔记本");
        }
    }

    public class Dell : NoteBook
    {
        public override void SaiHi()
        {
            Console.WriteLine("我是戴尔笔记本");
        }
    }

    public class MiBook : NoteBook
    {
        public override void SaiHi()
        {
            Console.WriteLine("我是小米笔记本");
        }
    }
}
